package com.xiangxiao.rpan.authority.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.xiangxiao.rpan.authority.tree.TreeNode;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Projectname: MenuQueryDto
 * @Author: xiangxiao
 * @Email: 573768011@qq.com
 * @Data:2023/4/13 1:34
 */
public class MenuQueryDto implements Serializable, Cloneable, TreeNode  {

  private static final long serialVersionUID = 3678525486245076451L;

  private Long id;

  private String name;

  private String url;

  private Long pid;

  private String resourceCode;

  private Integer type;

  private Integer available;

  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  private Date createTime;

  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  private Date updateTime;

  private String rightType;

  private boolean hashChild = false;

  private List<TreeNode> nextList;

  private List<TreeNode> childList;


  @Override
  public Long getId() {
    return this.id;
  }

  @Override
  public Long getParentId() {
    return this.pid;
  }

  @Override
  public String getName() {
    return this.name;
  }

  @Override
  public List<TreeNode> getChildList() {
    return new ArrayList<>();
  }

  @Override
  public TreeNode copyWithoutTreeInfo() {
    try {
      MenuQueryDto treeNode = (MenuQueryDto) super.clone();
      treeNode.childList = new ArrayList<>();
      return treeNode;
    } catch (CloneNotSupportedException e) {
      return null;
    }

  }

  @Override
  public boolean getHasChild() {
    return hashChild;
  }

  @Override
  public void setHasChild(boolean hasChild) {
    this.hashChild = hashChild;
  }
}
